

package com.ybwh.springboot2.common.mybatis.plus.page;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;


/**
 * 分页查询结果
 *
 * @param <T>
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PageRecords<T> {
    @ApiModelProperty(value = "当前页号")
    private long current;
    @ApiModelProperty(value = "每页大小")
    private long size;
    @ApiModelProperty(value = "总记录数")
    private long total;
    @ApiModelProperty(value = "记录列表")
    private List<T> records;

    public static <T> PageRecords<T> fromPageInfo(PageInfo<T> mpi) {
        return new PageRecords<>(mpi.getCurrent(), mpi.getSize(), mpi.getTotal(), mpi.getRecords());
    }
}
